// 73. 矩阵置零

/**
 Do not return anything, modify matrix in-place instead.
 */
function setZeroes(matrix: number[][]): void {
  // const set = new S
  const row = matrix.length;
  const col = matrix[0].length;
  const row_zero = new Set<number>();
  const col_zero = new Set<number>();

  for (let i = 0; i < row; i++) {
    for (let j = 0; j < col; j++) {
      if (!matrix[i][j]) {
        row_zero.add(i);
        col_zero.add(j);
      }
    }
  }

  for (let i = 0; i < row; i++) {
    for (let j = 0; j < col; j++) {
      if (row_zero.has(i) || col_zero.has(j)) {
        matrix[i][j] = 0;
      }
    }
  }
}
